<template>
  <el-container class="total">
    <el-header>
      <div class="headTitle">
        <!-- <img src="../assets/first.png" alt="" /> -->
        <span class="tlt">智能化高校课堂教学评估系统</span>
        <!-- <span class="tlt">基于多模态信息提取的高校课堂效果评估系统</span> -->
      </div>
      <el-dropdown class="userInfo" @command="handleCommand">
        <span class="el-dropdown-link">
          <!-- {{userlist.username}} -->
          <i>
            <el-avatar shape="square" :size="40" :src="squareUrl"></el-avatar>
          </i>
          <span>{{ userName }}</span>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="userinfo">个人中心</el-dropdown-item>
          <el-dropdown-item command="setting">设置</el-dropdown-item>
          <el-dropdown-item command="logout">注销登录</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </el-header>

    <el-container>
      <!-- 侧边栏区域 -->
      <el-aside :width="isCollapse ? '64px' : '200px'">
        <div class="toggle-button" @click="toggleCollaspe">|||</div>
        <!--侧边栏菜单区域-->
        <el-menu
          background-color="#74797A"
          text-color="#fff"
          active-text-color="#409EFF"
          :collapse="isCollapse"
          :collapse-transition="false"
          :router="true"
        >
          <!--一级菜单-->
          <el-submenu index="1">
            <!--一级菜单模板区-->
            <template slot="title">
              <!--图标-->
              <i class="el-icon-user-solid"></i>
              <!--文本-->
              <span>用户管理</span>
            </template>
            <!--二级菜单-->
            <el-menu-item index="users" @click="1 - 1">
              <template slot="title">
                <!--图标-->
                <i class="el-icon-menu"></i>
                <!--文本-->
                <span>用户列表</span>
              </template>
            </el-menu-item>
          </el-submenu>
          <!--一级菜单-->
          <el-submenu index="2">
            <!--一级菜单模板区-->
            <template slot="title">
              <!--图标-->
              <i class="el-icon-s-promotion"></i>
              <!--文本-->
              <span>课堂监测</span>
            </template>
            <!--二级菜单-->
            <el-menu-item index="monitor">
              <template slot="title">
                <!--图标-->
                <i class="el-icon-menu"></i>
                <!--文本-->
                <span>实时监测</span>
              </template>
            </el-menu-item>
            <el-menu-item index="results">
              <template slot="title">
                <!--图标-->
                <i class="el-icon-menu"></i>
                <!--文本-->
                <span>监测结果</span>
              </template>
            </el-menu-item>
          </el-submenu>
          <!--一级菜单-->
          <el-submenu index="3">
            <!--一级菜单模板区-->
            <template slot="title">
              <!--图标-->
              <i class="el-icon-s-cooperation"></i>
              <!--文本-->
              <span>班级管理</span>
            </template>
            <!--二级菜单-->
            <el-menu-item index="class">
              <template slot="title">
                <!--图标-->
                <i class="el-icon-menu"></i>
                <!--文本-->
                <span>班级管理</span>
              </template>
            </el-menu-item>
            <el-menu-item index="student">
              <template slot="title">
                <!--图标-->
                <i class="el-icon-menu"></i>
                <!--文本-->
                <span>学生管理</span>
              </template>
            </el-menu-item>
          </el-submenu>
          <!--一级菜单-->
          <el-submenu index="4">
            <!--一级菜单模板区-->
            <template slot="title">
              <!--图标-->
              <i class="el-icon-s-platform"></i>
              <!--文本-->
              <span>课程管理</span>
            </template>
            <!--二级菜单-->
            <el-menu-item index="course">
              <template slot="title">
                <!--图标-->
                <i class="el-icon-menu"></i>
                <!--文本-->
                <span>课程列表</span>
              </template>
            </el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <!-- 右侧内容主题部分 -->
      <el-main>
        <!--路由占位符-->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
// import Login from './Login.vue'
export default {
  data() {
    return {
      // 左侧菜单数据
      menulist: [],
      // 是否折叠
      isCollapse: false,
      // 被激活的链接地址
      // activePath: ''
      squareUrl:
        'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
      sizeList: ['large', 'medium', 'small'],
      // 个人信息表单设置为隐藏
      // addInformVisible: false
      userName: this.$store.state.userName
    }
  },
  methods: {
    exit() {
      window.sessionStorage.clear()
      this.$router.push('/login')
      //   Login.methods.resetLoginForm()
    },
    toggleCollaspe() {
      this.isCollapse = !this.isCollapse
    },
    handleCommand(command) {
      if (command === 'logout') {
        this.$confirm('此操作将注销登录, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            // 注销登陆
            window.sessionStorage.clear() // 清空token
            // window.sessionStorage.removeItem('user')
            this.$router.push('/login') // 返回登录页面
            // 清除当前用户信息(身份不一样：管理员/用户)
            // this.$store.commit('initRoutes',[])
            this.$message.success('注销成功')
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消操作'
            })
          })
      }
      if (command === 'userinfo') {
        console.log(command)
        this.$router.push('/userinfo')
      }
    }
  },
  mounted() {
    console.log(this.userName)
  }
}
</script>

<style lang="less" scoped>
.total {
  height: 100%;
}
.home-container {
  height: 100%;
}
.el-header {
  background-color: #b3c0d1;
  display: flex;
  justify-content: space-between;
  padding-left: 10px;
  align-items: center;
  color: #fff;
  font-size: 20px;
  position: relative;
  > div {
    // 嵌套
    // display: flex;
    align-items: center;
    .tlt {
      color:#0066CC;
      text-align: center;
      margin-left: 10px;
      font-size: 30px;
    }
  }
  .head_container {
    width: 250px;
    position: absolute;
    right: 200px;
    .wel {
      position: absolute;
      right: 0px;
    }
    .el-tag {
      position: absolute;
      right: 100px;
    }
  }
}

.el-aside {
  background-color: #fafbfd;
  .el-menu {
    border-right: none;
  }
}

.el-main {
  background-color: #eaedf1;
}
img {
  width: 50px;
  height: 50px;
}
.toggle-button {
  background-color: #969aa5;
  font-size: 10px;
  line-height: 24px;
  color: #fff;
  text-align: center;
  letter-spacing: 0.2em;
  cursor: pointer;
}
.el-aside[data-v-8dc7cce2]{
  background-color: #74797a;
}

.headTitle{
  height: 100%;
  width: 100%;
  text-align: center;
  line-height: 60px;
}
</style>
